package com.devsoft.foodfrenzy;
//this class is the base for all scenes; it sets up the variables and methods

import org.andengine.engine.Engine;
import org.andengine.engine.camera.Camera;
import org.andengine.entity.scene.Scene;
import org.andengine.entity.sprite.Sprite;
import org.andengine.entity.sprite.TiledSprite;
import org.andengine.opengl.vbo.VertexBufferObjectManager;

import android.app.Activity;

import com.devsoft.foodfrenzy.SceneManager.SceneType;

public abstract class BaseScene extends Scene
{
    protected Engine engine;
    protected Activity activity;
    protected ResourcesManager resourcesManager;
    protected VertexBufferObjectManager vbom;
    protected Camera camera;
    private Food food;
    private PowerUp power;
    
    
    public BaseScene()
    {
        this.resourcesManager = ResourcesManager.getInstance();
        this.engine = resourcesManager.engine;
        this.activity = resourcesManager.activity;
        this.vbom = resourcesManager.vbom;
        this.camera = resourcesManager.camera;
        createScene();
        
    }
    
    
    public abstract void createScene();
    
    
    public abstract void onBackKeyPressed();
    
    
    public abstract SceneType getSceneType();
    
    
    public abstract void disposeScene();
    
    
	public void createFood()
	{
		
    	food = new Food("Bananas", 2, new TiledSprite(230, 800, resourcesManager.food_bananas_region, vbom));
		Food.createFood(food);
		food = new Food("Bellpepper", .2, new TiledSprite(2300, 800, resourcesManager.food_bellpepper_region, vbom));
		Food.createFood(food);
		food = new Food("Burger", 1, new TiledSprite(230, 800, resourcesManager.food_burger_region, vbom));
		Food.createFood(food);
		food = new Food("Carrot", .2, new TiledSprite(230, 800, resourcesManager.food_carrot_region, vbom));
		Food.createFood(food);
		food = new Food("Cherry", .1, new TiledSprite(230, 800, resourcesManager.food_cherry_region, vbom));
		Food.createFood(food);
		food = new Food("Chicken", .5, new TiledSprite(230, 800, resourcesManager.food_chicken_region, vbom));
		Food.createFood(food);
		food = new Food("Corndog", .5, new TiledSprite(230, 800, resourcesManager.food_corndog_region, vbom));
		Food.createFood(food);
		food = new Food("Donut", .5, new TiledSprite(230, 800, resourcesManager.food_donut_region, vbom));
		Food.createFood(food);
		food = new Food("Egg", .2, new TiledSprite(230, 800, resourcesManager.food_egg_region, vbom));
		Food.createFood(food);
		food = new Food("Eggplant", 1, new TiledSprite(230, 800, resourcesManager.food_eggplant_region, vbom));
		Food.createFood(food);
		food = new Food("Grapes", .5, new TiledSprite(230, 800, resourcesManager.food_grapes_region, vbom));
		Food.createFood(food);
		food = new Food("Lemon", .2, new TiledSprite(230, 800, resourcesManager.food_lemon_region, vbom));
		Food.createFood(food);
		food = new Food("Mushroom", .2, new TiledSprite(230, 800, resourcesManager.food_mushroom_region, vbom));
		Food.createFood(food);
		food = new Food("Pineapple", 2, new TiledSprite(230, 800, resourcesManager.food_pineapple_region, vbom));
		Food.createFood(food);
		food = new Food("Strawberry", .1, new TiledSprite(230, 800, resourcesManager.food_strawberry_region, vbom));
		Food.createFood(food);
		food = new Food("Sushi", .5, new TiledSprite(230, 800, resourcesManager.food_sushi_region, vbom));
		Food.createFood(food);
		food = new Food("Tomato", 1, new TiledSprite(230, 800, resourcesManager.food_tomato_region, vbom));
		Food.createFood(food);
		food = new Food("Watermelon", 3, new TiledSprite(230, 800, resourcesManager.food_watermelon_region, vbom));
		Food.createFood(food);
    }
    
    public void createPowerUp()
    {
    	power = new PowerUp("Instant Cook", new Sprite(0, 0, resourcesManager.powerup1, vbom));
		PowerUp.createPowerUp(power);
		power = new PowerUp("Score Multiplier", new Sprite(0, 0, resourcesManager.powerup2, vbom));
		PowerUp.createPowerUp(power);
		power = new PowerUp("Special", new Sprite(0, 0, resourcesManager.powerup3, vbom));
		PowerUp.createPowerUp(power);
		power = new PowerUp("Double Pan", new Sprite(0, 0, resourcesManager.powerup4, vbom));
		PowerUp.createPowerUp(power);
		power = new PowerUp("BLANK", new Sprite(0, 0, resourcesManager.powerupblank, vbom));
		PowerUp.createPowerUp(power);
    }
    
    public TiledSprite findFoodSprite(int index)
    {
    	TiledSprite spriteType = null;
    	
    	switch(index){
		case 0:
			spriteType = new TiledSprite(230, 800, resourcesManager.food_bananas_region, vbom);
		break;
		case 1:
			spriteType = new TiledSprite(2300, 800, resourcesManager.food_bellpepper_region, vbom);
		break;
		case 2:
			spriteType = new TiledSprite(2300, 800, resourcesManager.food_burger_region, vbom);
		break;
		case 3:
			spriteType = new TiledSprite(2300, 800, resourcesManager.food_carrot_region, vbom);
		break;
		case 4:
			spriteType = new TiledSprite(2300, 800, resourcesManager.food_cherry_region, vbom); 
		break;
		case 5:
			spriteType = new TiledSprite(2300, 800, resourcesManager.food_chicken_region, vbom);
		break;
		case 6:
			spriteType = new TiledSprite(2300, 800, resourcesManager.food_corndog_region, vbom);
		break;
		case 7:
			spriteType = new TiledSprite(2300, 800, resourcesManager.food_donut_region, vbom);
		break;
		case 8:
			spriteType = new TiledSprite(2300, 800, resourcesManager.food_egg_region, vbom);
		break;
		case 9:
			spriteType = new TiledSprite(2300, 800, resourcesManager.food_eggplant_region, vbom);
		break;
		case 10:
			spriteType = new TiledSprite(2300, 800, resourcesManager.food_grapes_region, vbom);
		break;
		case 11:
			spriteType = new TiledSprite(2300, 800, resourcesManager.food_lemon_region, vbom);
		break;
		case 12:
			spriteType = new TiledSprite(2300, 800, resourcesManager.food_mushroom_region, vbom);
		break;
		case 13:
			spriteType = new TiledSprite(2300, 800, resourcesManager.food_pineapple_region, vbom);
		break;
		case 14:
			spriteType = new TiledSprite(2300, 800, resourcesManager.food_strawberry_region, vbom);
		break;
		case 15:
			spriteType = new TiledSprite(2300, 800, resourcesManager.food_sushi_region, vbom);
		break;
		case 16:
			spriteType = new TiledSprite(2300, 800, resourcesManager.food_tomato_region, vbom);
		break;
		case 17:
			spriteType = new TiledSprite(2300, 800, resourcesManager.food_watermelon_region, vbom);
		break;
	}
		return spriteType;
    	
    }
    
    public Sprite findPowerSprite(int index){
    	Sprite sprite = null;
    	switch(index){
    	case 0:
    		sprite = new Sprite(0, 0, resourcesManager.powerup1, vbom);
    		break;
    	case 1:
    		sprite = new Sprite(0, 0, resourcesManager.powerup2, vbom);
    		break;
    	case 2:
    		sprite = new Sprite(0, 0, resourcesManager.powerup3, vbom);
    		break;
    	case 3:
    		sprite = new Sprite(0, 0, resourcesManager.powerup4, vbom);
    		break;
    	case 4:
    		sprite = new Sprite(0, 0, resourcesManager.powerupblank, vbom);
    		break;
    	}
    	return sprite;
    }
    
}